<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        textarea{width:300px;height:500px}
    </style>
</head>
<body>
    <textarea id="txt1"></textarea>
    <input type="button" id="btn" value="转换">
    <textarea id="txt2" readonly></textarea>
</body>
<script>
    
    var txt1 = document.querySelector("#txt1")
    var txt2 = document.querySelector("#txt2")
    var btn = document.querySelector("#btn")

    // 正则的贪婪特性：尽可能的多匹配

    // 尽量少用通配符

    btn.onclick = function(){
        var str = txt1.value
        // 替换html标签
        str = str.replace(/<[^>]+>/g, "");
        txt2.value = str;
    }

</script>
</html>